package com.iespring.config;

import com.iespring.util.UrlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 静态文件上传配置
 * 如果有别的需求，可以在addResourceHandlers添加相关配置
 * @param null
 * @return
 * @author 杨宇健
 * @since 2022/12/29 13:08
 */

@ComponentScan("com.iespring.controller")
@Configuration
public class StaticFileConfig implements WebMvcConfigurer {
    @Autowired
    UrlUtil urlUtil;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //杨宇健 storage存储图片路径
        registry.addResourceHandler("storageImg/**").addResourceLocations("file:" +  urlUtil.getLocalPath("storageImg") + "/");
    }
}
